package com.liuche.pictureserver.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.liuche.pictureserver.config.mp.CustomMapper;
import com.liuche.pictureserver.pojo.domain.UserDO;

/**
 * 用户表 mapper
 *
 * @author liuche
 */
public interface UserMapper extends CustomMapper<UserDO> {

    /**
     * 根据账号查询用户
     *
     * @param userAccount 用户账户
     * @return 结果
     */
    default UserDO queryUserByAccount(String userAccount) {
        return selectOne(new LambdaQueryWrapper<UserDO>().eq(UserDO::getUserAccount, userAccount));
    }

    /**
     * 根据账号查询用户是否存在
     *
     * @param userAccount 用户账户
     * @return 结果
     */
    default long checkAccountExist(String userAccount) {
        return selectCount(new LambdaQueryWrapper<UserDO>().eq(UserDO::getUserAccount, userAccount));
    }

    default UserDO queryUserByAccountAndPwd(String userAccount, String userPassword) {
        return selectOne(new LambdaQueryWrapper<UserDO>().eq(UserDO::getUserAccount, userAccount).eq(UserDO::getUserPassword, userPassword));
    }

    // ===========================xml ===========================
}




